#!/bin/bash

source /home/shell/util.sh

requireJava
source /etc/profile.d/java.sh

if [ ! -f "/opt/gradle/bin/gradle" ]; then
    download /opt/gradle-bin.zip https://services.gradle.org/distributions/gradle-7.0-bin.zip
    unzip -d /opt/gradle /opt/gradle-bin.zip
    mv /opt/gradle/gradle-*/* /opt/gradle
    rm -rf /opt/gradle/gradle-*
    rm -rf /opt/gradle-bin.zip

tee /etc/profile.d/gradle.sh<<EOF
export PATH=\$PATH:/opt/gradle/bin
EOF

    chmod +x /etc/profile.d/gradle.sh
    chmod +x /opt/gradle/bin/gradle
fi

source /etc/profile.d/gradle.sh

printInfo "=================gradle================="
gradle -v
printInfo "=================gradle================="